package com.ncloud.crm.mapper;

import com.ncloud.crm.entity.order.OrderDiscntFee;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by shiqiang on 2017/5/12.
 */
@Mapper
public interface OrderDiscntFeeMapper {
    @Insert(value = "insert into bs_o_discnt_fee(cust_id,order_id,modify_tag,discnt_inst_id,discnt_id,discnt_name,fee_type,fee_code," +
            "pay_type,received_fee,pay_fee,balance,standard,billing_cycle,cycle_unit,begin_date,end_date,create_time,create_user," +
            "fee_value,fee_value2,str_value,str_value2) values(#{custId},#{orderId},#{modifyTag},#{discntInstId},#{discntId},#{discntName},#{feeType},#{feeCode}," +
            "#{payType},#{receivedFee},#{payFee},#{balance},#{standard},#{billingCycle},#{cycleUnit},#{beginDate},#{endDate},#{createTime},#{createUser}," +
            "#{feeValue},#{feeValue2},#{strValue},#{strValue2})")
    public int insertOrderDiscntFee(OrderDiscntFee discnt);

    @Select("select * from bs_o_discnt_fee where order_id = #{orderId}")
    @Results({ @Result(column = "order_id", property = "orderId"),@Result(column = "cust_id", property = "custId"),
            @Result(column = "modify_tag", property = "modifyTag"),
            @Result(column = "discnt_inst_id", property = "discntInstId"),
            @Result(column = "discnt_id", property = "discntId"),
            @Result(column = "discnt_name", property = "discntName"),
            @Result(column = "fee_type", property = "feeType"), @Result(column = "fee_code", property = "feeCode"),
            @Result(column = "pay_type", property = "payType"), @Result(column = "received_fee", property = "receivedFee"),
            @Result(column = "pay_fee", property = "payFee"), @Result(column = "balance", property = "balance"),
            @Result(column = "standard", property = "standard"), @Result(column = "billing_cycle", property = "billingCycle"),
            @Result(column = "cycle_unit", property = "cycleUnit"),
            @Result(column = "begin_date", property = "beginDate"),
            @Result(column = "end_date", property = "endDate"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "create_user", property = "createUser"),
            @Result(column = "fee_value", property = "feeValue"),
            @Result(column = "fee_value2", property = "feeValue2"),
            @Result(column = "str_value", property = "strValue"),
            @Result(column = "str_value2", property = "strValue2")
    })
    public List<OrderDiscntFee> getDiscntFeeByOrderId(Long orderId);

    @Select("select * from bs_o_discnt_fee where order_id = #{orderId} and discnt_inst_id = #{discntInstId} and modify_tag='1'")
    @Results({ @Result(column = "order_id", property = "orderId"),@Result(column = "cust_id", property = "custId"),
            @Result(column = "modify_tag", property = "modifyTag"),
            @Result(column = "discnt_inst_id", property = "discntInstId"),
            @Result(column = "discnt_id", property = "discntId"),
            @Result(column = "discnt_name", property = "discntName"),
            @Result(column = "fee_type", property = "feeType"), @Result(column = "fee_code", property = "feeCode"),
            @Result(column = "pay_type", property = "payType"), @Result(column = "received_fee", property = "receivedFee"),
            @Result(column = "pay_fee", property = "payFee"), @Result(column = "balance", property = "balance"),
            @Result(column = "standard", property = "standard"), @Result(column = "billing_cycle", property = "billingCycle"),
            @Result(column = "cycle_unit", property = "cycleUnit"),
            @Result(column = "begin_date", property = "beginDate"),
            @Result(column = "end_date", property = "endDate"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "create_user", property = "createUser"),
            @Result(column = "fee_value", property = "feeValue"),
            @Result(column = "fee_value2", property = "feeValue2"),
            @Result(column = "str_value", property = "strValue"),
            @Result(column = "str_value2", property = "strValue2")
    })
	public OrderDiscntFee getByDiscntInstIdAndOrderId(@Param("discntInstId")Long discntInstId, @Param("orderId")Long orderId);
}
